﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Data;

namespace MedicineTrackerWPF
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        Database _database = new Database();

        public MainWindow()
        {
            InitializeComponent();
            try
            {

                DataView dvTemp = new Database.Administrations().GetAllAdministrations();
                if (dvTemp.Count == 0)
                {
                    labelStatus.Content = "No Administrations in database.";
                    labelStatus.Visibility = System.Windows.Visibility.Visible;
                }
                else
                {
                    dataGridMain.DataContext = dvTemp;
                    labelStatus.Visibility = System.Windows.Visibility.Hidden;
                }
            }
            catch
            {
                MessageBox.Show("Database could not be contacted.", "Error");
            }
        }



        private void MenuItemExit_Click(object sender, RoutedEventArgs e)
        {
            this.Close();
        }

        private void radioButtonSingle_Checked(object sender, RoutedEventArgs e)
        {
            textBoxAnimalSingle.IsEnabled = true;
            dataGridGroup.IsEnabled = false;
            buttonAddGroup.IsEnabled = false;
            buttonRemoveGroup.IsEnabled = false;
        }

        private void radioButtonGroup_Checked(object sender, RoutedEventArgs e)
        {
            dataGridGroup.IsEnabled = true;
            buttonAddGroup.IsEnabled = true;
            buttonRemoveGroup.IsEnabled = true;
            textBoxAnimalSingle.IsEnabled = false;
        }
    }
}
